﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Xml;
using System.Xml.Linq;

namespace DynamicGeometry
{
    public interface IFigure : IEquatable<IFigure>
    {
        Drawing Drawing { get; set; }

        IEnumerable<IFigure> Dependencies { get; set; }
        IFigureList Dependents { get; }

        IFigure Clone();

        string Name { get; set; }
        bool Exists { get; set; }
        bool Selected { get; set; }
        bool Enabled { get; set; }
        bool Locked { get; set; }
        void UpdateExistence();
        void Recalculate();
        void UpdateVisual();

        IFigureStyle Style { get; set; }
        void ApplyStyle();

        /// <summary>
        /// Determines if a point lies on a figure and returns the figure in this case.
        /// </summary>
        /// <param name="point">Point's logical coordinates</param>
        /// <returns>A figure (usually itself or a child) if a point is on this figure, null otherwise</returns>
        IFigure HitTest(Point point);

        void OnAddingToCanvas(Canvas newContainer);
        void OnRemovingFromCanvas(Canvas leavingContainer);

        void OnAddingToDrawing(Drawing drawing);
        void OnRemovingFromDrawing(Drawing drawing);

        int ZIndex { get; set; }
        bool Visible { get; set; }

        string GenerateFigureName();

        void WriteXml(XmlWriter writer);
        void ReadXml(XElement element);
    }
}